package com.mt.roll.wms.utils;

import io.lettuce.core.StrAlgoArgs;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2022/3/19 9:52
 */
public class CommonUtil {
    public static ArrayList<Integer> byteToArray(Byte b){
        String tString = Integer.toBinaryString((b & 0xFF) + 0x100).substring(1);
        char[] chars = tString.toCharArray();
        ArrayList<Integer> res = new ArrayList<>();
        for(int i=0;i<chars.length;i++){
            res.add(Integer.valueOf(String.valueOf(chars[i])));
        }
        return res;
    }
    /**
     * 转换日期到本地日期时间格式
     * @param date
     * @return
     */
    public static LocalDateTime parseDate2LocalDateTime(Date date){
        if(date==null){
            return null;
        }
        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
    }
}
